package swm.hothead.rest.jerseydemo.resource;

import javax.ws.rs.Consumes;
import javax.ws.rs.FormParam;
import javax.ws.rs.GET;
import javax.ws.rs.PUT;
import javax.ws.rs.Path;
import javax.ws.rs.Produces;
import javax.ws.rs.core.MediaType;

import com.sun.jersey.spi.resource.Singleton;

@Singleton
@Path("/status")
public class MyResource {

	StatusInfoBean statusInfoBean = new StatusInfoBean();

	@GET
	@Produces(MediaType.APPLICATION_XML)
	public StatusInfoBean getStatus() {
		statusInfoBean.jobs
				.add(new JobInfoBean("sample.doc", "printing...", 13));
		System.out.println("sparta");
		return statusInfoBean;
	}

	@PUT
	@Consumes(MediaType.APPLICATION_XML)
	public synchronized void setStatus(@FormParam("xml") StatusInfoBean status) {
		System.out.println("This is sparta");
		this.statusInfoBean = status;
	}
}
